package info.nightbrest.agt.shared.rpc;

import com.google.gwt.core.client.JavaScriptObject;
import info.nightbrest.agt.client.AgtDispatcher;

public class SimpleResult implements AgtDispatcher.Result
{
	protected AgtDispatcher.Result.Status status = null;
	protected JavaScriptObject            data   = null;

	public SimpleResult()
	{
	}

	public SimpleResult(Status status)
	{
		this.status = status;
	}

	public SimpleResult(String value)
	{
		this.status = (Status) new SimpleResult(value);
	}

	public SimpleResult(String value, String message)
	{
		this.status = (Status) new SimpleResult(value, message);
	}

	@Override
	public Status getStatus()
	{
		return status;
	}

	@Override
	public void setStatus(Status status)
	{
		this.status = status;
	}

	@Override
	public void setData(JavaScriptObject jso)
	{
		this.data = jso.cast();
	}

	@Override
	public JavaScriptObject getData()
	{
		return data;
	}

	@Override
	public boolean isOk()
	{
		return (getStatus() != null && getStatus().isOk());
	}

}
